<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .box {
            margin: 20px 20px;
            padding: 10px;
            width: 250px;
            height: 400px;
            border: 1px solid rebeccapurple;
        }

        .box a {
            margin-left: 10px;
            font-size: 18px;
            text-decoration: none;
            color: black;
        }

        .box .active {
            color: aqua;
            border-top: 3px solid red;
        }

        .box .content {
            margin-top: 10px;
        }

        .box .content p {
            height: 25px;
        }

        .box .content p:hover {
            text-decoration-line: underline;
            color: blue;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="box">
        <a class="active" href="/video">视频</a>
        <a href="/liveBroadcast">直播</a>
        <div class="content">
        </div>
    </div>
</body>
</html>
<script>
    var btns = document.querySelectorAll('a')
    
    btns.forEach((item)=>{
        item.onclick = function(e){
            e.preventDefault()
            // console.log(this.href);
            history.pushState( {} , '' , this.href );
            switch( location.pathname ){
                    case '/video': video(); break;
                    case '/liveBroadcast': liveBroadcast(); break;
                }
        }
    })
    function video() {
        document.querySelector('.content').innerHTML = '<p>恋情曝光?李小璐摆拍</p><p>赵本山徒弟的片酬</p><p> “十亿富婆 李冰冰</p><p>赵本山徒弟的片酬</p><p>被老外退货的女星</p>'
        for (let i = 0; i < btns.length; i++) {
            btns[i].classList=''
        }
        btns[0].classList.add('active')
    }
    function liveBroadcast() {
        document.querySelector('.content').innerHTML = '<p>直播，双十一快递全球“云建工”</p><p>邂逅绝美云海日出</p><p>天舟五号已到位</p><p>济南趵突泉</p><p>立冬拥抱暖阳</p>'
        for (let i = 0; i < btns.length; i++) {
            btns[i].classList=''
        }
        btns[1].classList.add('active')
    }
</script>